#include"SList.h"
void SListTest01()
{
	//链表由一个一个节点生成
	//创建几个节点
	SLTNode* node1 = (SLTNode*)malloc(sizeof(SLTNode));
	node1->data = 1;
	SLTNode* node2 = (SLTNode*)malloc(sizeof(SLTNode));
	node2->data = 2;
	SLTNode* node3= (SLTNode*)malloc(sizeof(SLTNode));
	node3->data = 3;
	SLTNode* node4 = (SLTNode*)malloc(sizeof(SLTNode));
	node4->data = 4;
	//将四个节点连接起来
	node1->next = node2;
	node2->next = node3;
	node3->next = node4;
	node4->next = NULL;
	//调用链表打印
	SLTNode* plist = node1;
	SLPrint(plist);
}

void SListTest02()
{//测试尾插
	SLTNode* plist = NULL;//*plist第一个节点
	SLTPushBack(&plist, 1);//plist指向第一个结点的指针
	SLTPushBack(&plist, 2);//plist指向第一个结点的指针
	SLTPushBack(&plist, 3);//plist指向第一个结点的指针
	SLPrint(plist);//&plist指向第一个节点的指针的地址

	//测试销毁链表
	SListDesTroy(&plist);
	SLPrint(plist);

//测试头插
	/*SLTPushFront(&plist, 6);
	SLTPushFront(&plist, 8);
	SLPrint(plist);*/

	//测试尾删
	/*SLTPopBack(&plist);
	SLPrint(plist);
	SLTPopBack(&plist);
	SLPrint(plist);*/

	//测试头删
	/*SLTPopFront(&plist);
	SLPrint(plist);
	SLTPopFront(&plist);
	SLPrint(plist);*/

	//测试查找
	//SLTNode*  find=SLTFind(plist, 3);
	/*if (find == NULL)
	{
		printf("没有找到\n");
	}
	else {
		printf("找到了\n");
	}*/

	//测试在指定位置之前插入数据
	/*SLTNode* find = SLTFind(plist, 3);
	SLTInsert(&plist, find, 11);
	SLPrint(plist);*/

	//测试在指定位置之后插入数据
	/*SLTNode* find = SLTFind(plist, 3);
	SLTInsertAfter( find, 11);
	SLPrint(plist);*/

	//测试删除节点pos
	/*SLTNode* find = SLTFind(plist, 1);
	SLTErase(&plist,find);
	SLPrint(plist);*/

	//测试删pos之后的节点
	/*SLTNode* find = SLTFind(plist, 1);
	SLTEraseAfter(find);
	SLPrint(plist);*/
}
int main()
{
	//SListTest01();
	SListTest02();
	return 0;
}